SQL Server 存储过程返回值的几种方式 | 您所在的位置:网站首页 › return 多个值 › SQL Server 存储过程返回值的几种方式 |
(3)带输出参数的存储过程(存储过程中可以有return可以没有return) 例子A: —创建存储过程 create procedure sp_output @output int output as set @output = 121 return 1 —执行存储过程 执行下列,返回121 declare @out int exec sp_output @out output select @out 执行下列,返回1 declare @out int declare @count int exec @count = sp_output @out output select @count —说明 有return,只要查询输出参数,则查询结果为输出参数在存储过程中最后变成的值;只要不查询输出参数,则查询结果为return返回的值 例子B: —创建存储过程 create procedure sp_output @output int output as set @output = 121 —执行存储过程 执行下列,返回121 declare @out int exec sp_output @out output select @out 执行下列,返回0 declare @out int declare @count int exec @count = sp_output @out output select @count —说明 没有return,只要查询输出参数,则查询结果为输出参数在存储过程中最后变成的值;只要不查询输出参数,则查询结果为0 |
CopyRight 2018-2019 实验室设备网 版权所有 |